﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using eTerm.ASynClientSDK.Base;
using System.Text.RegularExpressions;

namespace eTerm.ASynClientSDK
{
    /// <summary>
    /// 编号提取
    /// </summary>
    public sealed class DETRCommand : ASynCommand
    {
        /// <summary>
        /// 指令结果解析适配器.
        /// </summary>
        /// <param name="Msg">指令结果集合.</param>
        /// <returns></returns>
        protected override ASyncResult ResultAdapter(string Msg)
        {
            DETResult result = new DETResult();

            return result;
        }

        /// <summary>
        /// Retrieves the specified code.
        /// </summary>
        /// <param name="Code">The code.</param>
        /// <returns></returns>
        public ASyncResult retrieve(string Code) {
            if (Regex.IsMatch(Code, @"-", RegexOptions.IgnoreCase | RegexOptions.Multiline)) {
                return base.GetSyncResult(string.Format(@"DETR:TN/{0}", Code));
            }
            else {
                return new RTCommand().retrieve(Code);
            }
        }
    }
}
